package com.example.gybicycle.service;

import com.example.gybicycle.common.entity.Result;
import com.example.gybicycle.common.sql.CrudService;
import com.example.gybicycle.dao.SysLogDao;
import com.example.gybicycle.entity.SysLog;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SysLogService extends CrudService<SysLogDao, SysLog> {
    @Override
    public SysLog get(String id) {
        SysLog table=super.get(id);
        return table;
    }
    public Result save(SysLog entity,String loginId){
        int num=0;
        if(entity.getStatus()==null)
            entity.setStatus(0);
        if(entity.getId()==null||entity.getId()==0){
            entity.setCreateBy(loginId);
            entity.setCreateTime(new Date());
            num=dao.insert(entity);
        }else {
            num=dao.update(entity);
        }
        if(num>0)
            return Result.success(entity);
        else 
            return Result.fail("保存失败");
    }
    public List<SysLog> findList(SysLog entity){
        List<SysLog> list=super.findList(entity);
        return list;
    }


}